<?php
/**
 * table.phtml
 * 
 * @category    Madoqua
 * @package     Module
 * @subpackage  BlogAdmin
 */

$this->headScript()->appendFile($this->adminFile('js/application/post-table.js'));

?>
<?php foreach($this->posts as $post) : ?>
<?php $rowClass = $this->alternate(array('n0', 'n1'));?>
<tr class="<?php echo $rowClass ?>">
    <td>
        <a href="<?php echo $this->url(array('controller' => 'post', 'action' => 'update', 'id' => $post->id), 'blog_admin', true); ?>">
            <?php echo $post->title; ?>
        </a>
        <div class="js-hidden delete-confirm <?php echo $rowClass ?>" id="delete-id-<?php echo $post->id ?>-confirm">
			<form action="<?php echo $this->url(array('controller' => 'post', 'action' => 'delete', 'id' => $post->id), 'blog_admin', true); ?>" method="post">
				<fieldset>
					<input type="submit" class="confirm-delete" name="confirm" value="Yes, delete this post" />
					<? /* It is not always necessary click the submit button to submit a form, so use a hidden field */ ?>
					<input type="hidden" name="submit" value="1" />
				</fieldset> 
			</form> 
        </div>
    </td>
    
    <td>
        <a href="<?php echo $this->url(array('controller' => 'post', 'action' => 'update', 'id' => $post->id), 'blog_admin', true); ?>">
            <?php echo $this->date($post->posted); ?>
        </a>
    </td>
    
    <td>
    	<a href="javascript:;" class="js-hidden delete" id="delete-id-<?php echo $post->id ?>"><span>delete</span></a>
    </td>
    
</tr>
<? endforeach; ?>
